//
//  Person.m
//  Archiver
//
//  Created by LiJonius on 16/3/24.
//  Copyright © 2016年 LiJonius. All rights reserved.
//

#import "Person.h"

@implementation Person

//自定义对象归档
- (void)encodeWithCoder:(NSCoder *)aCoder{
    
    //[super encodeWithCooder:aCoder];
    //超类需要适用协议NSCoding,NSObject本身是不适用NSCoding协议的
    [aCoder encodeObject:self.name forKey:@"name"];
    //对象，关键字
    //[aCoder encodeConditionalObject:self.name forKey:@"name"];
    [aCoder encodeInt:self.age forKey:@"age"];
    //整型变量，关键字
    
    
    [aCoder encodeObject:self.student forKey:@"student"];
}

//初始化反归档
- (id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.age = [aDecoder decodeIntForKey:@"age"];
        
        self.student = [aDecoder decodeObjectForKey:@"student"];
    }
    return self;
}
@end
